<!doctype html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>修改</title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../../css/mui.css" rel="stylesheet" />
		<link href="../../css/list.css" rel="stylesheet" />
		<script src="../../js/mui.min.js"></script>
		 <script src="../../js/app.js"></script>
		 <link href="../../css/style.css" rel="stylesheet" />
		 <link href="../../css/icons-extra.css" rel="stylesheet"/>
<link rel="stylesheet" href="../css/detail.css" type="text/css" />
		 		<!--<script src="../js/jquery-3.3.1.js"></script>-->
		 		<style type="text/css">
.speak{
	/*输入框居中漂浮*/
position: fixed;
width:100%;
top:30%;
/*left:50%;*/
margin: auto auto;
padding: 0 5px;
text-align: center;
		 			}
</style>
</head>
<header class="mui-bar mui-bar-nav">
    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
  <h1 class="mui-title">项目概况<span id="title"></span></h1><p id="titleright" style="float: right;font-size: 0.6em;">举报</p>
</header>
    <div class="mui-content">
    <div  style="width:100%;margin:0 auto;text-align:center" id="image"></div>
    <div id="neirong" class="mui-content-padded"></div>
    <li class="mui-content-padded" style="border-bottom:solid 1px #333;"><span>创作团队</span></li>
    <div class="slide-box" id="team"></div>
    <!--出品公司-->
    <li class="mui-content-padded" style="border-bottom:solid 1px #333;"><span>新闻动态</span></li>
    <span id="news" class="slide-box"></span>
    <!--项目概况表格-->
    <div id="table" class="mui-content-padded"></div>

    </div>
    <div id="speak" class="speak" style="display:none;background: #DDDDDD;">
		<p id='speaktitle' style="margin:auto auto;font-size: 1.2em;color:#EC971F">请输入新内容</p>
		<textarea id="value" type="text"rows="10"placeholder="请输入"></textarea>
		<div style="margin-top: -24px;border-radius:5px;">
		<input id="pubish" style="font-size: 18px;margin: 2px 5px;padding:0 10px;float: right;" value="确认" type="submit">
		<input  style="font-size: 18px;margin: 2px 5px;float: right;padding:0 10px;" value="取消" type="submit" onclick="javascript:(document.getElementById('speak').style.display='none')">
		</div>
</div>
<!--上传附件进度显示-->
<!--<input type="text" name="val" id="val" value="" />-->
<script type="text/javascript">
	var tid=localStorage[htmlname+'id'];
	//发布关联团队返回触发函数
	window.addEventListener('renovate', function(e){
//		alert(JSON.stringify(e.detail));
		//裁剪后返回的图片显示在image标签下的img
//		document.getElementById('image').src=e.detail.image;
	//主图裁剪上传返回数据执行更新
	  location.reload(); //刷新
	 });
	  //发布关联新闻返回触发函数
	window.addEventListener('refreshnews', function(e){
//		alert(JSON.stringify(e.detail));
//		getnews(tid,'item',0);
		//裁剪后返回的图片显示在image标签下的img
//		document.getElementById('image').src=e.detail.image;
	//主图裁剪上传返回数据执行更新
	  location.reload(); //刷新
	  });
function show_hidden(trid){
	var abc='';
	trid=document.getElementById(trid);
	if(trid.style.display=="block"){
	    trid.style.display='none';
	}else{
	    trid.style.display='block';
	}
}

value=document.getElementById('value');
   //输入框控制
function modifyinput(tid,key){
	speaktitle=document.getElementById('speaktitle');
	value.value=document.getElementById(key).innerText;
	if(key=='password'){
		value.rows='1';//文本输入框显示的高度行数
		speaktitle.innerText='请输入新密码,仅支持数字和字母';
	}else{
		value.rows='8';//文本输入框显示的高度行数
		speaktitle.innerText='请输入修改的内容';
	}
	document.getElementById('speak').style.display='block';//显示输入框
	var tid=tid||'';
	var key=key ||'';
		document.getElementById('pubish').onclick=function(){
			document.getElementById('speak').style.display='none';//隐藏发布按钮
			modify(tid,key);
			}
}
//删除div 下的id文档
function delete_html(thisid){
	var tid=document.getElementById(thisid);
	tid.parentNode.removeChild(tid);//删除div
}
//删除图片
function imgdelete(img,tid,act){
    mui.confirm('删除这条内容，确认？', '', ['否', '是'], function(e) {
        if (e.index == 1) {
        	apptoken['tid']=tid;
			apptoken['img']=img;
			//deleteteam=请求服务器删除团队简历
			apptoken['act']=act||'deleteteam';
			//relationoff=请求服务器关闭新闻动态挂载
			if(apptoken['act']=='relationoff'){
				//进入news新闻页处理
				apptoken['act']='modify';
				apptoken['v']='0';
				apptoken['k']='relationoff';
				mod='/news';
			}else{
				mod='/item';
			}
	mui.post(home.hos+mod+'/admin',apptoken,function(data){//获取关联数据
//		alert(data);
	 	if(data==200){
	 		var tid=document.getElementById(img);
			tid.parentNode.removeChild(tid);//窗口文档中删除图片div
	 		plus.ui.toast('删除成功');
	 	}else{
	 		plus.ui.toast('操作失败');
	 	}})
        } else {
            plus.ui.toast('取消操作');
        }
       })
}
p=0;
//获取团队信息
 function getteam(num,tid){
	apptoken['tid']=tid||localStorage.itemmodifyid;
	apptoken['act']='team';
	if(num==1){
		p=p+1
	}else{
		p=0;
	};
			apptoken['relation']='team';
			apptoken['p']= p;
	 mui.post(home.hos+'/item?tid='+tid,apptoken,function(data){
			if(isJSON(data)){
					result=JSON.parse(data);//获取信息
			var val1='';
			var val2='';
			var val3='';
			var val4='';
for(var i=0;i<result.length;i++){
			if(result[i].confirm=='1'){
			confirm='拟约';
		}else{
			confirm='已定';
		}
	if('undefined'==result[i]['image']){
			pics=''
	}else{
			pics='<div id="'+result[i]['image']+'" class="con" ><div class="pic" style="max-width:100px;min-height:10px;padding:2px;position:relative" ><p style="position:absolute;text-align:center;border-radius:9px;color:#fff;line-height:1em;background:red;padding:3px">✖</p><img  src="'+home.uploads+'/img/item/team/min'+result[i]['image']+'" onclick="imgdelete(\''+result[i]['image']+'\',\''+result[i]['id']+'\')" /><h5>'+result[i]['duty']+'['+confirm+']</h5> <p>'+result[i]['name']+'</p></div></div>';
//			alert(home.uploads+'/img/item/team/min'+result[i]['image']);
	};
if(result[i]['class']=='1'){
		val1+=pics;
	}else if(result[i]['class']=='2'){
		val2+=pics;
	}else if(result[i]['class']=='3'){
		val3+=pics;
	}else if(result[i]['class']=='4'){
		val4+=pics;
	}
}
//创作团队
document.getElementById('team').innerHTML='<div class="con"><div class="pic" style="width:1.5em;">主创团队</div></div>'+val1+'<div class="con"><div class="pic" style="width:1.5em;">演员</div></div>'+val3+'<div class="con"><div class="pic" style="width:1.5em;">技术团队</div></div>'+val2+'<div class="con"><div class="pic" style="width:1.5em;">合作运营</div></div>'+val4+'<div class="con"><div class="pic" ><img onclick="goto(\'item\',\'admin\',\'teampublish\','+tid+')" src="../../images/iconfont-tianjia.png"></img></div></div>';

}
},'text');
}
var	p= 0;
 //获取相关新闻信息
 function getnews(num,tid){
 	if(num==1){p=p+1}else{p=0;};
 	apptoken['p']= p;
	apptoken['relation']='item';
	apptoken['tid']=tid ||localStorage.itemmodifyid;
	apptoken['act']='relationlist';
	 mui.post(home.hos+'/news?p='+p+'&'+'tid='+tid+'&'+'rel=item',apptoken,function(data){
//	 	alert('这是关联新闻'+data)
if(isJSON(data)){
		result=JSON.parse(data);//获取信息
var val1='';
var val2='';
var val3='';
var val4='';
for(var i=0;i<result.length;i++){
			if(result[i].relationoff=='1'){
			confirm='<p style="position:absolute;text-align:center;border-radius:9px;color:#fff;line-height:1em;background:red;padding:3px">✖</p>';
		}else{
			confirm='<p style="position:absolute;text-align:center;border-radius:9px;color:#00FF7F;line-height:1em;background:#00FF7F;padding:3px">●</p>';
		}
result[i]['image']=result[i]['img']
	if('undefined'==result[i]['image']){
			pics=''
	}else{
			pics='<div id="'+result[i]['image']+'" class="con"style=""><div class="pic" style="max-width:100px;min-height:10px;padding:2px;max-height:280px;position:relative" >'+confirm+'<img  src="'+home.uploads+'/img/news/'+result[i]['image']+'" onclick="imgdelete(\''+result[i]['image']+'\',\''+result[i]['id']+'\',\'relationoff\')" /> <p style="font-size:0.5em">发布人：'+result[i]['username']+result[i]['content']+' </p></div></div>';

	};
	result[i]['class']=result[i]['zan'];
if(result[i]['class']=='1'){
		val1+=pics;
	}else if(result[i]['class']=='2'){
		val2+=pics;
	}else if(result[i]['class']=='3'){
		val3+=pics;
	}else if(result[i]['class']){
		val4+=pics;
	}
}
//相关新闻
document.getElementById('news').innerHTML='<div class="con"><div class="pic" style="width:1.5em;">新闻动态</div></div>'+val4+'<div class="con"><div class="pic" ><img onclick="goto(\'news\',\'admin\',\'relationpublish\','+tid+')" src="../../images/iconfont-tianjia.png"></img></div></div>';
}
},'text');
}

function goto(method,room,htmlname,this_id){
	//数据库存储当前点击id值
//	alert(method+room+htmlname);
localStorage[method+room+htmlname+'id']=this_id;
mui.openWindow('../../'+method+'/'+room+'/'+htmlname+'.html?tid='+this_id+'&mod=item');
}
apptoken['tid']=tid;//获取详情id
apptoken['act']='detail';
mui.post(home.hos+'/item/admin?tid='+apptoken['tid'],apptoken,function(data){

	if(isJSON(data)){
		result=JSON.parse(data);//获取信息
		jsonarrfor(result);//加载详情信息

		}else{
			alert('页面加载失败，或不存在，请重新尝试');
			return false;
    	}
})
//主图大图
function imageplay(image,tid){
	document.getElementById('image').innerHTML='<img  style="width:95%;" src="'+home.uploads+'/img/item/'+image+'" onerror="this.onerror=null;this.src=\'../../images/iconfont-tianjia.png\'" />';
}
function jsonarrfor(result){
	//获取团队信息
	getteam(0,result.id);
	//获取相关新闻信息
	getnews(0,result.id);
//完成进度
if(result.status==1){
	casestate='<span style="color:#00EE00;">●</span><span style="border-radius:25px;border:2px solid #a1a1a1;padding:2px 5px">聊聊</span>';
}else{
	casestate='<span style="color:red;">■</span>';
}
//完成进度
var Completion=Math.round(result.sharenow/result.share*10000)/100;
//发布日期
var createtime=new Date(parseInt(result.createtime) * 1000).format('yyyy年M月d日');
//状态
var stage='<option>待审核</option><option>广电备案</option><option>融资</option><option>筹备</option><option>拍摄</option><option>后期制作</option><option>广电终审</option><option>发行</option>';

var val='<div style="text-align:center"><h3>'+result.classname+':'+result.title+'</h3><p  style="background: transparent;">运行阶段'+casestate+'<span style="border-radius:25px;border:2px solid #a1a1a1;padding:2px 5px" id="stage">'+result.stage+'</span><span  style="background: transparent;">更新<select name="sel" id="rtl"onchange="select('+result.id+',\'stage\')" style="height:2em;margin:2px" >'+stage+'</select></span></p><h4>简介[<span onclick="modifyinput('+result.id+',\'synopsis\')" style="color:red">修改+</span>]</h4><p><span id="synopsis">'+result.synopsis+'</span></p></div>';


var table='<div class="list-head" ><table><tr><td width="110px">项目名称</td><td>'+result.title+'</td></tr><tr><td width="110px">项目类型</td><td>'+result.classname+'</td></tr><tr><td width="110px">出品公司</td><td>'+result.produce+'</td></tr><tr><td width="110px">项目负责人</td><td>'+result.head+'</td></tr><tr><td width="110px">支持入股方式</td><td>资金入股,资源入股,技术入股</td></tr><tr><td width="110px">接受资源类别</td><td>器材,场景,食宿,车辆,版权,其他品牌产品</td></tr><tr><td width="110px">接受技术类别</td><td>摄影,艺术指导,导演,美术,宣传,发行,特效</td></tr><tr><td>预计回报日期</td><td>'+result.repaytime+'日</td></tr><tr><td>拆分股份数</td><td>'+result.share+'股/份</td></tr><tr><td>每份估价</td><td>'+result.moneyunit+'元</td></tr><tr><td>预估总值约</td><td>'+(result.share*result.moneyunit/10000)+'万</td></tr><tr><td colspan="2">已被认领'+result.sharenow+'股</td></tr><tr><td colspan="2">剩余'+(result.share-result.sharenow)+'股待认领</td></tr><tr><th  colspan="2" style="text-align:center;color:red;" >项目策划案(下载密码：<span id="password">'+result.password+'</span>)<div id="inputdiv" style="width:100%;height:30px;border: 1px solid;margin-bottom:10px; background-color:rgb(240,240,240);border-radius:5px;" onclick="input()">添加文件:(支持后缀名pdf/ppt/doc/pptx/docx)</div><input style="display:none" class="file" type="file" id="fileToUpload" onchange="getFilename()"><input type="button" onclick="uploadFile('+result.id+')" value="立即上传"><input type="button" onclick="modifyinput('+result.id+',\'password\')" value="重置密码"></th></tr><tr><th  colspan="2" ><span style="text-align:center;">*实时状况通知*</span>[<span onclick="modifyinput('+result.id+',\'notice\')" style="color:red">修改+</span>]<p><span id="notice" >'+result.notice+'</span></p></th></tr></table></div>';
//形象头像
if(result.poster && result.poster.length>6){
imageplay(result.poster,result.id);	
}
//显示内容
document.getElementById('neirong').innerHTML=val;
document.getElementById('titleright').innerHTML='<div id="report" style="margin-top:10px;float:right">举报次数'+result.report+'</div>';
document.getElementById('table').innerHTML=table;
//document.getElementById('source').innerHTML='<p style="border-bottom:solid 1px #333;"><span>发布人:'+result.username+'</span><span style="margin-left:20px">发布于：'+createtime+'</span></p>';
document.getElementById('team').innerHTML='<li id="zhuchuangb"></li><li style="margin-top: 1em;"><span onclick="modifyinput('+result.id+',\'notice\')" style="color:red">[添加+]</span><span style="margin-right:1em;float: right;"onclick="get(1)">更多</span></li>';
//get(0);
}
//更新进度
function select(tid,type){
if(type=='stage'){
	  var rtl=document.getElementById("rtl");
	  value.value=rtl.value;
	  modify(tid,type);
//  upajax(tid,type,document.getElementById('val').value,'updata');
}
//	alert(tid+type+'您现在要结束项目码');
}

//修改组件
function modify(tid,type){
	//k=键；act=修改方法，tid=主题id，type=修改类型；
	apptoken['k']=type||'';
	if(type=='synopsis' || type==''){//如果修改的页面是内容多行文本，将会替换换行符
	apptoken['v']=getFormatCode(value.value) ||'';
	}else{
		apptoken['v']=value.value ||'';
	}
	apptoken['tid']=tid||'';
	apptoken['act']='modify';
	mui.post(home.hos+'/item/admin',apptoken,function(data){
		alert(data);
		if(isJSON(data)){
//			alert(value.value);
			jsondata=JSON.parse(data);
			if(jsondata.status && jsondata.status==200){
				document.getElementById(type).innerText=value.value;
			}else{
				plus.ui.toast('操作失败');
			}
			//修改加密状态显示/或者加密
//			encrypystatus(jsondata.encrypt,tid);
		}
	})
}

//触发input单击事件选择上传文件
function input(){
	document.getElementById('fileToUpload').click();
}
//选择完毕要上传的文件，把文件名推送到div显示出来
function getFilename(){
	document.getElementById('inputdiv').innerHTML=document.getElementById('fileToUpload').files[0].name;
}

    function uploadFile(tid) {
    	var maxsize=1024*1024*8;//限制最大上传不不超过8mb
        var checklogin = status;
        var file = document.getElementById('fileToUpload');
        if(tid && file.files[0]) {
            var fd = new FormData();  
            apptoken['tid']=tid;
            apptoken['act']='upload';
            fd.append('file', file.files[0]);
            for(var p in apptoken){
            fd.append(p, apptoken[p]);	
            }
        	filesize = file.files[0].size;
        	if(filesize>maxsize){
        	alert('上传文件不能超过'+maxsize+'MB;请压缩后上传。');
        	return false;
        	}
        	var fileName = file.files[0].name.substring(file.files[0].name.lastIndexOf(".")+1).toLowerCase();

	        if(fileName !="doc" && fileName !="pdf" && fileName !="docx" && fileName !="ppt" && fileName !="pptx"){
	        	alert('上传后缀名为doc/pdf/docx/ppt/pptx类型的文件');
	        	return false;
	        }
            var xhr = new XMLHttpRequest();
            w=plus.nativeUI.showWaiting("开始上传...");//进度信息
            xhr.upload.addEventListener("progress", uploadProgress, false);  
            xhr.addEventListener("load", uploadComplete, false);  
            xhr.addEventListener("error", uploadFailed, false);  
            xhr.addEventListener("abort", uploadCanceled, false);  
            xhr.open("POST", home.hos+'/item/admin');  
            xhr.send(fd);
        } else {  
            swal({     
                title: "请选择要上传的文件",     
                text: "",     
                type: "warning"});
        }  
    }  
  function swal(evt){
  	//返回信息输出
  	alert(evt.title+evt.text);
  }
    function uploadProgress(evt) {
        if(evt.lengthComputable) {  
            var percentComplete = Math.round(evt.loaded * 100 / evt.total);  
			w.setTitle("已上传"+percentComplete.toString()+"%");//上传进度
        } else {  
            swal({title:"上传失败",text:evt.target.responseText,type:"warning"}); 
        }  
    }  
  
    function uploadComplete(evt) {
    	w.close();
    	if(evt.target.responseText==200){
    		swal({title:"上传成功",text:evt.target.responseText,type:"warning"});
    	}else{
    		swal({title:"上传失败",text:evt.target.responseText,type:"warning"}); 
    	}
        /* 服务器端返回响应时候触发event事件*/  
//      alert(evt.target.responseText);    
		    }  
  
    function uploadFailed(evt) {  
        swal({title:"传输过程出现错误",text:"",type:"warning"});  
    }  
  
    function uploadCanceled(evt) {  
        swal({title:"传输已取消",text:"",type:"warning"});  
    }  
  </script>